{include file="public/header" /}
<body style="margin-top:30px;font-size:16px;">
	<div class="container">
		<div class="row clearfix">
			<form role="form" class="col-md-12">
				<input type="hidden" name="id" value="{$id}"/>
				<div class="form-group">
					<label for="title">标题</label>
					<input type="text" class="form-control" id="title" name="title" placeholder="请输入标题" value="{:isset($find['title'])?$find['title']:''}" />
				</div>
				<div class="form-group">
					<label for="tuition">费用</label>
					<input type="text" class="form-control" id="tuition" name="tuition" placeholder="请输入费用，只能整数，免费输入0"  value="{:isset($find['tuition'])?$find['tuition']:''}" />
				</div>
				<div class="form-group">
					<label for="people_num">人数</label>
					<input type="text" class="form-control" id="people_num" name="people_num" placeholder="请输入招收人数，不限制输入0" value="{:isset($find['people_num'])?$find['people_num']:''}" />
				</div>
				<div class="form-group clearfix">
					<label for="teacher_name">老师头像</label><br/>
					<button type="button" class="btn btn-danger" id="up_s">上传</button><br/>
					<div id="demo_s">
						{if(!empty($find['teacher_img']))}
							<div class="upload_pic_li" style="position:relative; float:left; margin:0 10px 10px 0;"><img style="width:100px;height:100px;margin-left:10px;" src="{$find['teacher_img']}" class="layui-upload-img"><input type="hidden" name="teacher_img" value="{$find['teacher_img']}"/></div>
						{/if}
					</div>
				</div>
				<div class="form-group">
					<label for="teacher_name">老师名</label>
					<input type="text" class="form-control" id="teacher_name" name="teacher_name" placeholder="请输入讲课老师" value="{:isset($find['teacher_name'])?$find['teacher_name']:''}"/>
				</div>
				<div class="form-group">
					<label for="teacher_phone">老师手机</label>
					<input type="text" class="form-control" id="teacher_phone" name="teacher_phone" placeholder="请输入讲课老师手机，报名后才会显示给用户" value="{:isset($find['teacher_phone'])?$find['teacher_phone']:''}"/>
				</div>
				<div class="form-group">
					<label for="class_start_date">开课时间</label>
					<input type="date" class="form-control" id="class_start_date" name="class_start_date" value="{:isset($find['class_start_date'])?$find['class_start_date']:''}" />
				</div>
				<div class="form-group">
					<label for="class_time">上课时间</label>
					<input type="text" class="form-control" id="class_time" name="class_time" placeholder="如：周一 20点-22点" value="{:isset($find['class_time'])?$find['class_time']:''}" />
				</div>
				<div class="form-group">
					<label for="class_hour">课时</label>
					<input type="text" class="form-control" id="class_hour" name="class_hour" placeholder="请输入课时，45分钟一课时" value="{:isset($find['class_hour'])?$find['class_hour']:''}" />
				</div>
				<div class="form-group">
					<label for="class_end_date">报名截止</label>
					<input type="date" class="form-control" id="class_end_date" name="class_end_date" value="{:isset($find['class_end_date'])?$find['class_end_date']:''}" />
				</div>
				<div class="form-group">
					<label for="address">上课教室</label>
					<input type="text" class="form-control" id="address" name="address" placeholder="请输入上课教室，如二(3)班" value="{:isset($find['address'])?$find['address']:''}" />
				</div>
				<div class="form-group">
					<label for="license">课程介绍</label><br/>
					<button type="button" class="btn btn-danger" id="up">上传</button><br/>
					<div id="demo">
						{if(!empty($find['intr']))}
							{foreach($find['intr_s'] as $intr_s_v)}
								<div class="upload_pic_li" style="position:relative; float:left; margin:0 10px 10px 0;"><img style="width:100px;height:100px;margin-left:10px;" src="{$intr_s_v}" class="layui-upload-img"><input type="hidden" name="teacher_img" value="{$intr_s_v}"/><a class="close-img" href="javascript:;" onclick="deleteImage(this);return false;"></a></div>
							{/foreach}
						{/if}
					</div>
				</div>
			</form>
			<button type="button" class="btn btn-block btn-success" id="submit">添加</button>
		</div>
	</div>
	<script type="text/javascript">
		layui.use(['upload'],function(){
			$ = layui.jquery;

			upload = layui.upload;
			upload.render({
				elem: "#up",
				url: "/index.php/index/index/upload_img",
				done: function(res,title){
					if(res.code > 0){
						return layer.msg("上传失败，"+res.msg);
					}else{
						$("#demo").append('<div class="upload_pic_li" style="position:relative; float:left; margin:0 10px 10px 0;"><img style="width:100px;height:100px;margin-left:10px;" src="'+ res.data +'" class="layui-upload-img"><input type="hidden" name="intr[]" value="'+res.data+'"/><a class="close-img" href="javascript:;" onclick="deleteImage(this);return false;"></a></div>');
					}
				}
			});
			upload.render({
				elem: "#up_s",
				url: "/index.php/index/index/upload_img",
				done: function(res,title){
					if(res.code > 0){
						return layer.msg("上传失败，"+res.msg);
					}else{
						$("#demo_s").html('<div class="upload_pic_li" style="position:relative; float:left; margin:0 10px 10px 0;"><img style="width:100px;height:100px;margin-left:10px;" src="'+ res.data +'" class="layui-upload-img"><input type="hidden" name="teacher_img" value="'+res.data+'"/></div>');
					}
				}
			});

			$("#submit").click(function(){
				$.post("/index.php/index/my/course_add_json",$('form').serialize(),function(res){
					if(res.code != 0){
						alert(res.msg);
						return false;
					}
					if({$id} == 0){
						alert('添加成功');
					}else{
						alert('修改成功');
					}
					window.location.href = '/index.php/index/my/index';
				},'json');
			})
		});
	</script>
{include file="public/tail" /}